/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mantechhelpdesk.entity;

import java.io.Serializable;
import java.util.Date;
import mantechhelpdesk.dao.DbConnection;
import mantechhelpdesk.dao.DepartmentsDao;
import mantechhelpdesk.dao.ThreadsDao;
import mantechhelpdesk.dao.UsersDao;

/**
 *
 * @author DinhThang
 */
public class Complaints implements Cloneable, Serializable {

    /**
     * Persistent Instance variables. This data is directly mapped to the
     * columns of database table.
     */
    private int complaintID;
    private int threadID;
    private String threadName;
    private int userID;
    private String userName;
    private int departmentID;
    private String departmentName;
    private String title;
    private String complaintContent;
    private Date createTime;
    private boolean isFinished;
    private Date finishedTime;
    private boolean hasReplied;
    private int userRef;
    private int priority;

    /**
     * Constructors. DaoGen generates two constructors by default. The first one
     * takes no arguments and provides the most simple way to create object
     * instance. The another one takes one argument, which is the primary key of
     * the corresponding table.
     */
    public Complaints() {
    }

    public Complaints(int ComplaintIDIn) {

        this.complaintID = ComplaintIDIn;

    }

    /**
     * Get- and Set-methods for persistent variables. The default behaviour does
     * not make any checks against malformed data, so these might require some
     * manual additions.
     */
    public int getComplaintID() {
        return this.complaintID;
    }

    public void setComplaintID(int ComplaintIDIn) {
        this.complaintID = ComplaintIDIn;
    }

    public int getThreadID() {
        return this.threadID;
    }
    
    public void setThreadID(int ThreadIDIn) {
        try {
            ThreadsDao threadsDao = new ThreadsDao();
            Threads thread = threadsDao.getObject(DbConnection.getConnection(), ThreadIDIn);
            if (null != thread && thread.getThreadName().length() > 0) {
                threadName = thread.getThreadName();
            }
            this.threadID = ThreadIDIn;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public String getThreadName() {
        return threadName;
    }

    public void setThreadName(String threadName) {
        this.threadName = threadName;
    }
    
    
    public int getUserID() {
        return this.userID;
    }

    public void setUserID(int UserIDIn) {
        try {
            UsersDao usersDao = new UsersDao();
            Users user = usersDao.getObject(DbConnection.getConnection(), UserIDIn);
            if (null != user && user.getUsername().length() > 0) {
                userName = user.getUsername();
            }
            this.userID = UserIDIn;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
    
    
    public int getDepartmentID() {
        return this.departmentID;
    }

    public void setDepartmentID(int DepartmentIDIn) {
        try {
            DepartmentsDao departmentsDao = new DepartmentsDao();
            Departments depart = departmentsDao.getObject(DbConnection.getConnection(), DepartmentIDIn);
            if (null != depart && depart.getDepartmentName().length() > 0) {
                departmentName = depart.getDepartmentName();
            }
            this.departmentID = DepartmentIDIn;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }
    
    
    public String getTitle() {
        return this.title;
    }

    public void setTitle(String TitleIn) {
        this.title = TitleIn;
    }

    public String getComplaintContent() {
        return this.complaintContent;
    }

    public void setComplaintContent(String ComplaintContentIn) {
        this.complaintContent = ComplaintContentIn;
    }

    public Date getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Date CreateTimeIn) {
        this.createTime = CreateTimeIn;
    }

    public boolean getIsFinished() {
        return this.isFinished;
    }

    public void setIsFinished(boolean IsFinishedIn) {
        this.isFinished = IsFinishedIn;
    }

    public Date getFinishedTime() {
        return this.finishedTime;
    }

    public void setFinishedTime(Date FinishedTimeIn) {
        this.finishedTime = FinishedTimeIn;
    }

    public boolean getHasReplied() {
        return this.hasReplied;
    }

    public void setHasReplied(boolean HasRepliedIn) {
        this.hasReplied = HasRepliedIn;
    }

    public int getUserRef() {
        return this.userRef;
    }

    public void setUserRef(int UserRefIn) {
        this.userRef = UserRefIn;
    }

    public int getPriority() {
        return this.priority;
    }

    public void setPriority(int PriorityIn) {
        this.priority = PriorityIn;
    }

    /**
     * setAll allows to set all persistent variables in one method call. This is
     * useful, when all data is available and it is needed to set the initial
     * state of this object. Note that this method will directly modify instance
     * variales, without going trough the individual set-methods.
     */
    public void setAll(int ComplaintIDIn,
            int ThreadIDIn,
            int UserIDIn,
            int DepartmentIDIn,
            String TitleIn,
            String ComplaintContentIn,
            Date CreateTimeIn,
            boolean IsFinishedIn,
            Date FinishedTimeIn,
            boolean HasRepliedIn,
            int UserRefIn,
            int PriorityIn) {
        this.complaintID = ComplaintIDIn;
        this.threadID = ThreadIDIn;
        this.userID = UserIDIn;
        this.departmentID = DepartmentIDIn;
        this.title = TitleIn;
        this.complaintContent = ComplaintContentIn;
        this.createTime = CreateTimeIn;
        this.isFinished = IsFinishedIn;
        this.finishedTime = FinishedTimeIn;
        this.hasReplied = HasRepliedIn;
        this.userRef = UserRefIn;
        this.priority = PriorityIn;
    }

    public Complaints(int ComplaintIDIn,
            int ThreadIDIn,
            int UserIDIn,
            int DepartmentIDIn,
            String TitleIn,
            String ComplaintContentIn,
            Date CreateTimeIn,
            boolean IsFinishedIn,
            Date FinishedTimeIn,
            boolean HasRepliedIn,
            int UserRefIn,
            int PriorityIn) {
        this.complaintID = ComplaintIDIn;
        this.threadID = ThreadIDIn;
        this.userID = UserIDIn;
        this.departmentID = DepartmentIDIn;
        this.title = TitleIn;
        this.complaintContent = ComplaintContentIn;
        this.createTime = CreateTimeIn;
        this.isFinished = IsFinishedIn;
        this.finishedTime = FinishedTimeIn;
        this.hasReplied = HasRepliedIn;
        this.userRef = UserRefIn;
        this.priority = PriorityIn;
    }
}
